<template>
  <div class="body">
    <div class="top">
      <div class="item">
        <el-icon style=" transform:translateY(2px)">
          <Cellphone/>
        </el-icon>
        <span>账号查找</span>
        <input type="text" placeholder="请输入内容" v-model="qq">
        <button @click="findBytel">搜索</button>
      </div>
      <div class="span"></div>

    </div>
    <div class="main">
    <div style="max-width: 830px; margin:0 auto;">
        <el-table :data="goods[0]" style="width: 100%" >
        <el-table-column fixed prop="qq" label="account" width="250"/>
        <el-table-column prop="score" label="score" width="120"/>
        <el-table-column prop="pwd" label="password" width="250"/>
        <el-table-column prop="time" label="time" width="200"/>


      </el-table>
      <div style="height: 20px;"></div>
      <el-pagination background layout="prev, pager, next" :total="total" @current-change="handleCurrentChange"/>
    </div>
    </div>

  </div>
</template>

<script setup>
import {
  ref,
  reactive, inject, onMounted
} from "vue";
import {ElMessage} from "element-plus";
const axios = inject('$axios')
const  qq =ref("")
const total = ref(0)
const goods = reactive([
  [{}]
])




const findBytel=()=>{
  if(!qq.value.length){
    alert("请输入信息")
  }
  else{
    axios.get("user/account?qq="+qq.value.trim()).then(res=>{
        if(res.data.code==1){
          goods[0] = res.data?.data
        }
      else   ElMessage.error(res.data.msg)

  }).catch(err => {

  })

  }
}

const handleCurrentChange = val => {
  axios.get("/user?p=" + val + "&s=10").then(res => {
    console.log(res)
    goods[0] = res.data?.data?.data
  }).catch(err => {

  })
}



onMounted(() => {
  axios.get("/user?p=1&s=10").then(res => {
    console.log(res)
       goods[0] = res.data?.data?.data
    total.value = res.data.data.p * 10
  }).catch(err => {

  })
})


</script>

<style scoped lang="less">
.el-table th {
  padding: 0 !important;

}

.body {
  width: 100%;
  height: 100%;

  .main {
    background-color: #ffffff;
    width: 80%;
    margin: 10px auto;
    padding: 20px;
    border-radius: 10px;
    box-sizing: border-box;
    text-align: center;
  }

  .top {
    width: 80%;
    height: 100px;
    background-color: #ffffff;
    border-radius: 10px;
    margin: 10px auto;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }

  .item {
    font-size: 17px;
    color: #606266;

    input {
      width: 300px;
      height: 30px;
      border: 1px solid #409EFF;
      background-color: #ffffff;
      border-radius: 10px 0 0 10px;
      text-indent: 1em;
      margin-left: 10px;
    }

    button {
      width: 50px;
      height: 32px;
      border-radius: 0 10px 10px 0;
      color: #fff;
      background-color: #409EFF;
      border: 2px solid #409EFF;
    }

    span {
      margin-left: 5px;
    }

  }

  .span {
    margin: auto 20px;
  }
}
</style>